package com.lechuang.songbo.view.activity.recyclerView;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.MemoryCategory;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.lechuang.songbo.R;
import com.lechuang.songbo.model.bean.GetBean;
import com.lechuang.songbo.model.bean.HomeSearchResultBean;
import com.lechuang.songbo.view.activity.home.OnKeyShareCallback;
import com.lechuang.songbo.view.defineView.SpannelTextView;

import java.util.Locale;

/**
 * Author: guoning
 * Date: 2017/10/6
 * Description:  赚列表页面的Adapter
 */

public class CrazyInfoAdapter extends BaseQuickAdapter<HomeSearchResultBean.ProductListBean, GetInfoHolder> {


    private OnKeyShareCallback callback;
    private Context context;

    public CrazyInfoAdapter(Context context) {
        super(R.layout.item_crazy);
        this.context = context;
    }

    @Override
    protected void convert(final GetInfoHolder helper, final HomeSearchResultBean.ProductListBean listInfo) {
        SpannelTextView spannelTextView = helper.getView(R.id.spannelTextView);
        spannelTextView.setShopType(Integer.parseInt(listInfo.shopType));
        spannelTextView.setDrawText(listInfo.name);
        Glide.with(context).load(listInfo.imgs).into((ImageView) helper.getView(R.id.img));
        Glide.get(context).setMemoryCategory(MemoryCategory.LOW);
        //优惠价
        helper.setText(R.id.tv_nowprice, "¥" + listInfo.preferentialPrice);
        //原价
        helper.setText(R.id.tv_oldprice, "¥" + listInfo.price);
        ((TextView)helper.getView(R.id.tv_oldprice)).getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG);
        //券金额
        helper.setText(R.id.tv_quan, "领券    立减" + listInfo.couponMoney);

    }


    public void setOnKeyShareCallback(OnKeyShareCallback callback) {
        this.callback = callback;
    }

}
